import 'package:efood_multivendor/data/api/api_client.dart';
import 'package:efood_multivendor/data/model/body/review_body.dart';
import 'package:efood_multivendor/util/app_constants.dart';
import 'package:get/get.dart';

class ProductRepo extends GetxService {
  final ApiClient apiClient;
  ProductRepo({required this.apiClient});

  Future<Response> getPopularProductList(String type) async {
    return await apiClient
        .getData('${AppConstants.POPULAR_PRODUCT_URI}?type=$type');
  }

  Future<Response> getProductDetail(int id) async {
    return await apiClient.getData('${AppConstants.PRODUCT_DETAILS_URI}$id');
  }

  Future<Response> getReviewedProductList(String type) async {
    return await apiClient
        .getData('${AppConstants.REVIEWED_PRODUCT_URI}?type=$type');
  }

  Future<Response> submitReview(ReviewBody reviewBody) async {
    return await apiClient.postData(
        AppConstants.REVIEW_URI, reviewBody.toJson());
  }

  Future<Response> submitDeliveryManReview(ReviewBody reviewBody) async {
    print(reviewBody.toJson().toString());
    return await apiClient.postData(
        AppConstants.DELIVER_MAN_REVIEW_URI, reviewBody.toJson());
  }

  Future<Response> cancelDeliveryManReviewPopup(
      DelvieryManCancelPopupBody reviewBody) async {
    print(reviewBody.toJson().toString());
    return await apiClient.postData(
        AppConstants.DELIVER_MAN_REVIEW_URI, reviewBody.toJson());
  }

  Future<Response> getUnreviewedOrdersData(int offset, int limit) async {
    return await apiClient.getData(
        AppConstants.UNREVIEWED_ORDERS_ID + '?limit=$limit&&offset=$offset');
  }
}
